package com.intelligentmeterreadingsys.otherequipment.activity;

import java.util.List;

import com.intelligentmeterreadingsys.R;
import com.intelligentmeterreadingsys.otherequipment.db.EquipementDao;
import com.intelligentmeterreadingsys.povo.TypePoVo;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

/**
 * 设备查询之设置条件
 * @author king
 *
 */
public class EquipementConditionActivity extends Activity implements OnItemSelectedListener{
    
	public Button button;//查询
	public EditText edit1;//设备编号
	public EditText edit2;//设备安装地址
	public Spinner spinner1;//设备类型
	public Spinner spinner2;//巡检状态
	public Spinner spinner3;//查询状态
	public String[] date1;
	public String[] date2;
	public String[] date3;
	private String number;
	private String adds;
	private String type;
	private String serchstatus;
	private String querystatus;
	
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	public String getAdds() {
		return adds;
	}
	public void setAdds(String adds) {
		this.adds = adds;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getSerchstatus() {
		return serchstatus;
	}
	public void setSerchstatus(String serchstatus) {
		this.serchstatus = serchstatus;
	}
	public String getQuerystatus() {
		return querystatus;
	}
	public void setQuerystatus(String querystatus) {
		this.querystatus = querystatus;
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.other_equipment_condition);
		init();
	}
    public void init(){
    	querystatus="巡检";
    	serchstatus="正常";
    	type="请选择";
    	button=(Button)findViewById(R.id.other_equipment_condition_query);
    	spinner1=(Spinner)findViewById(R.id.other_equipment_condition_type);
    	spinner2=(Spinner)findViewById(R.id.other_equipment_condition_serchstatus);
    	spinner3=(Spinner)findViewById(R.id.other_equipment_condition_veiwtype);
    	edit1=(EditText)findViewById(R.id.other_equipment_condition_number);
    	edit2=(EditText)findViewById(R.id.other_equipment_condition_adds);
    	EquipementDao dao = new EquipementDao(this);

		List<TypePoVo> list = dao.queryOrderType();
		
		if (list != null && list.size() > 0) {
			date1 = new String[list.size() + 1];
			date1[0] = "请选择";
			for (int i = 0; i < list.size(); i++) {
				date1[i + 1] = list.get(i).getName();
			}
		} else {
			date1 = new String[] { "请选择" };
		}
		dao.close();
		date2=new String[]{"未巡检","已巡检"};
		date3=new String[]{"巡检","增加","修改"};
		ArrayAdapter<String> ada = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, date1);// 放数据
		ada.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner1.setAdapter(ada);
		ArrayAdapter<String> ada1 = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, date2);// 放数据
		ada1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner2.setAdapter(ada1);
		ArrayAdapter<String> ada2 = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, date3);// 放数据
		ada2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner3.setAdapter(ada2);
		spinner1.setOnItemSelectedListener(this);
		spinner2.setOnItemSelectedListener(this);
		spinner3.setOnItemSelectedListener(this);
		
		
    }
	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
			long arg3) {
		if(arg1.getId()==spinner1.getId()){
			type=arg0.getItemAtPosition(arg2).toString();
		}else if(arg1.getId()==spinner2.getId()){
			serchstatus=arg0.getItemAtPosition(arg2).toString();
		}else if(arg1.getId()==spinner3.getId()){
			querystatus=arg0.getItemAtPosition(arg2).toString();
		}
		
	}
	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		
		
	}
}
